package com.example.jack.community.view.home.homeAdapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.bumptech.glide.Glide;
import com.example.jack.community.R;
import com.example.jack.community.data.HomePopularBean;

import java.util.ArrayList;

import de.hdodenhof.circleimageview.CircleImageView;

/**
 * Created by vveng on 2017/11/2 09: 01
 *
 * @mail: vvengStruggle@163.com
 * 热门的适配器
 */

public class HomePpAdapter extends RecyclerView.Adapter<HomePpAdapter.MyViewHolder> {

    private Context mContext;
    private ArrayList<HomePopularBean> beans;

    public void setData(ArrayList<HomePopularBean> mbeans) {
        this.beans = mbeans;
    }

    public HomePpAdapter(Context context) {
        mContext = context;
    }

    public HomePpAdapter(Context context, ArrayList<HomePopularBean> beans) {
        mContext = context;
        this.beans = beans;
    }

    @Override
    public HomePpAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.home_popular_recyclerview_item, parent, false);
        MyViewHolder holder = new MyViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(HomePpAdapter.MyViewHolder holder, int position) {
   Glide.with(mContext).load(beans.get(position).getPopularImage()).into(holder.ppImage);
        holder.ppImage.setAlpha(0.5f);
    }

    @Override
    public int getItemCount() {
        return beans.size();
    }

    public class MyViewHolder extends RecyclerView.ViewHolder {
        private CircleImageView ppImage;


        public MyViewHolder(View view) {
            super(view);
          ppImage = (CircleImageView) view.findViewById(R.id.popular_im_tx);

        }
    }
}
